Re: How to add a control to a page added to a tab control

--- In harbourminigui@yahoogroups.com, "roberto.mao"
<roberto.mao@...> wrote:
>
> Hi, Grigory,
>
> I'm not making myself clear, sorry :o(
>
> I know how to user the TAB control, and it works fine.
>
> The problems is AFTER I have created a tab control.
> If I need another page I can user AddControl, it's ok, but
> the problem is how to insert a new control inside this new page.
> I can do that but the control must exist in a form to be added to
> the new page and it's not "nice".
>
> Is there another way to get that?
>
> thanks for your attention
>

Hi Roberto,

> Is there another way to get that?
Yes, it is.
Kindly try the following working sample (take a look for clause OF
Form_1 at Browse control's definition):

#include "minigui.ch"

Static nPage := 0

Function Main()

DEFINE WINDOW Form_1 ;
AT 0, 0 ;
WIDTH ( GetDesktopWidth() / 2 + 10 ) HEIGHT ( GetDesktopHeight
() / 2 + 60 ) ;
TITLE "Test Browse Tab" ;
MAIN ;
ON INIT AddBrowsePage()

DEFINE MAIN MENU

DEFINE POPUP 'Test'
MENUITEM 'Add a New page' ACTION AddBrowsePage()
SEPARATOR
MENUITEM 'Exit' ACTION ThisWindow.Release
END POPUP
END MENU

DEFINE TAB Tab_1 ;
OF Form_1 ;
AT 0, 0 ;
WIDTH ( GetDesktopWidth() / 2 ) ;
HEIGHT ( GetDesktopHeight() / 2 ) ;
VALUE 1

END TAB

END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

Return .T.

Function AddBrowsePage()
Local cDbfBrowse

nPage++
Form_1.Tab_1.AddPage ( nPage, 'Page '+ltrim(str(nPage)) )
cDbfBrowse := "Browse_"+ltrim(str(nPage))

@ 0 , 0 BROWSE &cDbfBrowse ;
OF Form_1 ;
WIDTH 0 ;
HEIGHT 0 ;
HEADERS {'one','two'} ;
WIDTHS {60,60} ;
WORKAREA alias() ;
FIELDS {'field1','field2'} ;
VALUE 1

Form_1.Tab_1.AddControl( cDbfBrowse, nPage, 60, 50 )
Form_1.&(cDbfBrowse).Width := GetDesktopWidth() / 4
Form_1.&(cDbfBrowse).Height := GetDesktopHeight() / 4
Form_1.Tab_1.Value := nPage

Return .T.

--
Regards,